package it.unibo.deis.lia.servicemmhc.clock;

import java.io.*;
import java.net.*;

public class ServerClock extends Thread
{    
  static final int MAX_REQ = 5;
  private int port;
  
  
  public ServerClock(int port) {
	super();
	this.port = port;
}



public void run(){
	  try
	    {
	      // crea e connette la socket
	      ServerSocket so = new ServerSocket(port, MAX_REQ);
	      System.out.print("Server HTTP: inizializzato sulla porta ");
	      System.out.println(so.getLocalPort());

	      while(true)
	      {
	        // si mette in ascolto
	        Socket newso = so.accept();
	        System.out.println("Server HTTP: ricevuta richiesta");
	        
	        // esegue un thread in modo parallelo
	        new ServerClockThread(newso,port).start();
	      }      
	    } catch (IOException e) {System.out.println("ERRORE: " + e);}
  }
  
  
  
  public static void main(String args[])
  {
   ServerClock clock=new ServerClock(2900);
   clock.start();
  }
} // class ServerHTTP
